package com.second.controller.search;

import com.second.model.dto.LAndR.LAndRResult;
import com.second.model.pojo.FShop;
import com.second.service.impl.FShopServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("fr")
public class SearchController {
    @Autowired
    private FShopServiceImpl shopsService;
    @GetMapping("search/{shopName}")
    public String search(@PathVariable(name = "shopName")  String shopName,
                         HttpServletRequest request) {
        if (null!=shopName){
            List<FShop> shopList2=shopsService.findByName(shopName);
            request.setAttribute("shopList",shopList2);
            return "jsp/search/search";
        }else return "jsp/classify/classify";


    }
    @PostMapping("sc/{shopName}")
    @ResponseBody
    public LAndRResult select(@PathVariable(name = "shopName")  String shopName
    )  {
        System.out.println(shopName);
        FShop fShop=new FShop();
        List<FShop> shopList2=shopsService.findByName(shopName);
        System.out.println(shopList2);

        return new LAndRResult("200","类型",shopList2);
    }

}
